package com.piiworks.google;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import org.apache.log4j.Logger;
import org.jdom2.JDOMException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Gpx2kml
{
	private static Logger logger = Logger.getLogger(Gpx2kml.class);

	public static void main(String[] args)
	{
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(GpxConfig.class);

		Gpx2kmlService gpx2kmlService = context.getBean(Gpx2kmlService.class);

		try
		{
			OutputStream os = new FileOutputStream("src\\main\\resources\\routes\\tapolca.kml");
			gpx2kmlService.convert(new File("src\\main\\resources\\routes\\tapolca.gpx"), os);
			os.flush();
		}
		catch (JDOMException e)
		{
			logger.error(e);
		}
		catch (IOException e)
		{
			logger.error(e);
		}
		finally
		{
			context.close();
		}
	}
}
